package com.yuzhyn.hiops.app;

import com.yuzhyn.azylee.core.systems.commons.SystemPropertyTool;
import com.yuzhyn.azylee.core.systems.commons.SystemTypeTool;
import com.yuzhyn.azylee.websdk.args.WebSdkStarter;
import com.yuzhyn.hiops.app.aarg.R;
import com.yuzhyn.hiops.common.model.UserInfo;
import lombok.extern.slf4j.Slf4j;
import org.ehcache.config.builders.CacheConfigurationBuilder;
import org.ehcache.config.builders.CacheManagerBuilder;
import org.ehcache.config.builders.ResourcePoolsBuilder;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;

@Slf4j
@EnableCaching
@SpringBootApplication(scanBasePackages = {"com.yuzhyn.hiops", "com.yuzhyn.azylee.websdk"})
public class HiopsAppApplication {

    public static void main(String[] args) {
        // 初始化资源数据（创建目录结构，释放资源）

        // WebSdk 初始化
        WebSdkStarter.init(R.AppName);

        R.Cache.CacheManager = CacheManagerBuilder.newCacheManagerBuilder().build();
        R.Cache.CacheManager.init();
        R.Cache.UserInfo = R.Cache.CacheManager.createCache("UserInfo",
                CacheConfigurationBuilder.newCacheConfigurationBuilder(String.class, UserInfo.class, ResourcePoolsBuilder.heap(1024)));

        log.info("~");
        SpringApplication.run(HiopsAppApplication.class, args);
        log.info("/");
        log.info("/");
        log.info("============================================================");
        log.info("============================================================");
        log.info("***HIOPS***::CODE::LaunchedSuccessfully");
        log.info("***HIOPS***::LOG::xxxx服务启动成功");
        log.info("");
        log.info("操作系统：" + SystemTypeTool.getOSname().toString());
        if (!SystemTypeTool.isLinux()) {
            log.error("环境异常：由于大部分功能仅支持Linux系统，Windows系统运行时部分功能将不可用");
        }
        log.info("运行路径：" + SystemPropertyTool.userDir());
        log.info("============================================================");
        log.info("============================================================");
        log.info("/");
        log.info("/");
    }

}
